class getAttrDemo:
    a = 1
    b = 2
#获取不存在的属性值，可以直接设置默认值
print(getattr(getAttrDemo,'c','默认替换值'))